home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / teco.zip / KILL.C < prev    next >
C/C++ Source or Header  |  1986-07-15  |  909b  |  39 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. kill()
  6. {
  7. #include "teco.h"
  8.  
  9.     int tmp;                /* Scratch variable     */
  10.     int wrk;                /* Another scratch var. */
  11.  
  12.     tmp=bufptx;                /*  ...end of dlt */
  13.     if (number < 1) while (1) {        /* delete backwrd */
  14.         if (!bufptx) goto axe;
  15.         if (toascii(buffer[--bufptx]) == 13) {
  16.             if (! number++) {
  17.                 if (toascii(buffer[bufptx+1]) == 10) {
  18.                     bufptx++;
  19.                 }
  20.                 goto axe;
  21.             }
  22.         }
  23.     }
  24.     if (number > 0) while (1) {        /* delete forward */
  25.         if (tmp+1 > bufptr) goto axe;
  26.         if (toascii(buffer[++tmp]) == 13) {
  27.             if (toascii(buffer[tmp+1]) == 10) ++tmp;
  28.             if (! --number) goto axe;
  29.         }
  30.     }
  31.  
  32. axe:    memcpy(&buffer[bufptx+1],&buffer[tmp+1],bufptr-bufptx);
  33.     bufptr=bufptr+bufptx-tmp;        /* Show deleted.. */
  34.     if (bufptr < bufptx) {            /* Impose  sanity */
  35.         bufptx=bufptr;            /*  ...stop this  */
  36.     }
  37.     return;                    /* Eat more stuff */
  38. }
  39.